using System.Globalization;
using NUnit.Framework;
using ValidationFramework.Configuration;
using ValidationFramework.Extensions;

namespace ValidationFramework.Tests.Configuration
{
    [TestFixture]
	public class DateTimeConversionRuleConfigReaderTest
    {

        #region Methods

        [Test]
        public void ReadConfig()
        {
            const string validatorXml = "<rule errorMessage='hello' ruleSet='foo' typeName='DateTimeConversionRule' dateTimeFormatInfoTypeName='System.Globalization.DateTimeFormatInfo' dateTimeFormatInfoPropertyName='CurrentInfo' dateTimeStyles='AllowWhiteSpaces'/>";
            var ruleData = (RuleData.Read(validatorXml.ToXmlReader()));
			var rule = (DateTimeConversionRule)ConfigurationService.GetRule(ruleData, typeof(string).TypeHandle);
            Assert.AreEqual("hello", rule.ErrorMessage);
			Assert.AreEqual(DateTimeFormatInfo.CurrentInfo, rule.DateTimeFormatInfo);
			Assert.AreEqual(DateTimeStyles.AllowWhiteSpaces, rule.DateTimeStyles);

        }

        #endregion


    }
}